package com.glorysoft.tonglingxjpda.bindingadapter

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.glorysoft.tonglingxjpda.R


object ImageAdapter {

    @BindingAdapter(value = ["imageFile"], requireAll = false)
    @JvmStatic
    fun setBitmap(image: ImageView, path: String) {
        if (path.isNullOrEmpty()){
            image.setImageResource(R.drawable.ic_launcher_background)
            return
        }
        Glide.with(image.context).load(path)
                .error(R.drawable.ic_launcher_background).into(image)
    }

}